home *** CD-ROM | disk | FTP | other *** search
- Path: netline-fddi.jpl.nasa.gov!usenet
- From: David Yan <yan@aig.jpl.nasa.gov>
- Newsgroups: comp.lang.c++
- Subject: HELP: Sorting linked lists in STL
- Date: Fri, 01 Mar 1996 09:52:40 -0800
- Organization: Jet Propulsion Laboratory
- Message-ID: <31373968.55AC@aig.jpl.nasa.gov>
- NNTP-Posting-Host: keynes.jpl.nasa.gov
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
-
- I am having problems with the sort() method of the list<T> class in STL.
-
- I have a linked list which is declared as list<foo*> and have the
- operator < overloaded:
-
- bool operator < (const foo *a, const foo *b) const
- { // some debug print statements
- return *a < *b;
- }
-
- bool foo::operator < (const foo &b) const
- {
- // some debug print statement and some operations ...
- }
-
-
- STL specs say that list<T>::sort() makes use of the operator < of T
- to sort the linked list.
- But unfortunately, when I call list<foo*>::sort(), both of the above
- overloaded operator < are not called.
-
- (I am using SparcWorks 4.0 with ObjectSpace STL.)
-
- Any input will be much appreciated.
-
- David Yan
- yan@aig.jpl.nasa.gov
-